package com.liqi.frame.comm.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Configuration;

/**
 * springboot项目启动之后自动启动默认浏览器
 * Created by liqi on 2019/9/26 0026.
 */
//@SpringBootConfiguration
@Configuration
public class AutoStartProjectInDefaultBrowser implements CommandLineRunner {
    @Value("${server.port}")
    private String port;

    @Override
    public void run(String... args) throws Exception {
        try {
//            System.out.println("http://127.0.0.1:" + port);
//            Runtime.getRuntime().exec("cmd /c start http://127.0.0.1:" + port);
//            System.out.println("http://127.0.0.1:" + port);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
